package com.xiguthings.waka.web.controller.wechat.wx.tmpltMsg;

import java.util.HashMap;

import com.alibaba.fastjson.JSONObject;




abstract public class TltMsg {
	private JSONObject msg;
	protected HashMap<String, Element> data;

	public TltMsg() {
		msg = new JSONObject();
		data = new HashMap<String, Element>();
	}

	public TltMsg(String receiver) {
		this();
		msg.put("touser", receiver);
	}

	public TltMsg(String receiver, String url) {
		this();
		msg.put("touser", receiver);
		msg.put("url", url);
	}

	abstract String getTltId();

	public void addValue(String name, String value) {
		data.put(name, new Element(value, null));
	}

	public void addValue(String name, String value, String color) {
		data.put(name, new Element(value, color));
	}

	public void addReceiver(String receiver) {
		msg.put("touser", receiver);
	}

	public void addDetail(String url) {
		msg.put("url", url);
	}

	public void setTip(String tip) {
		addValue("first", tip);
	}

	public String getJsonValu() {
		msg.put("template_id", getTltId());
		msg.put("data", data);
		return msg.toString();
	}
}
